<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class index extends CI_Controller {

    function __construct() {
        parent::__construct();
        if(!login_user()){
       show_jump('已退出登录', site_url('manage/login/index'));
       }
        $this->load->model('manage/m_index');
         $this->load->model('manage/m_statistics');
    }
    function  index(){
    
    	 $this->load->view('manage/index_index');
    }
    function top(){
          $user = login_user();
          $data['admin']=$user;
    	  $this->load->view('manage/index_top',$data);
    }
    function left(){
    	 $this->load->view('manage/index_left');
    }
    function main(){
    	//每天注册用户数
    	if($_POST['reg_start']){
    		$reg_start = strtotime($_POST['reg_start']);
    		$data['reg_start'] = $_POST['reg_start'];
    	}else{
    		$reg_start = 0;
    	}
    	if($_POST['reg_end']){
    		$reg_end = strtotime($_POST['reg_end']);
    		$data['reg_end'] = $_POST['reg_end'];
    	}else{
    		$reg_end = 0;
    	}
    	$data['register_info'] = $this->m_statistics->get_banseinfo($reg_start,$reg_end,0,50);
    	$data['register_count'] = $this->m_statistics->get_banseinfo_count();
      //每天消息数
    	if($_POST['message_start']){
    		$message_start = strtotime($_POST['message_start']);
    		$data['message_start'] = $_POST['message_start'];
    	}else{
    		$message_start = 0;
    	}
    	if($_POST['message_end']){
    		$message_end = strtotime($_POST['message_end']);
    		$data['message_end'] = $_POST['message_end'];
    	}else{
    		$message_end = 0;
    	}
    	$data['message_result'] = $this->m_statistics->get_message($message_start,$message_end,0,30);
    	$data['message_count'] = $this->m_statistics->get_message_count()+$this->m_statistics->get_message_bak_count();
    	if($result_count=count($data['message_result'])<30){
    		$message_bak_result = $this->m_statistics->get_message_bak($message_start,$message_end,0,30-$result_count);
    		foreach ($message_bak_result as $k=>$mr){
    			$data['message_result'][$result_count+$k]=$mr;
    		}
    	}    	
  
    
    	
    	//每天新增产品数
    	if($_POST['product_start']){
    		$product_start = strtotime($_POST['product_start']);
    		$data['product_start'] = $_POST['product_start'];
    	}else{
    		$product_start = 0;
    	}
    	if($_POST['product_end']){
    		$product_end = strtotime($_POST['product_end']);
    		$data['product_end'] = $_POST['product_end'];
    	}else{
    		$product_end = 0;
    	}
    	$data['product_result'] = $this->m_statistics->get_pro($product_start,$product_end,0,50);
    	$data['product_count'] = $this->m_statistics->get_pro_count();
    	//交友对数
    	$data['friend_count'] = $this->m_statistics->get_friend_count();
    	 $this->load->view('manage/index_main',$data);
    }
    function bottom(){
    	 $this->load->view('manage/index_bottom');
    }
    function drag(){
    	 $this->load->view('manage/index_drag');
    }
}
?>